#include "CActiveHelper.h"

template<class T>
CActiveHelper<T>::CActiveHelper(const TPriority& aPriority)
: CActive(aPriority)
{
CActiveScheduler::Add(this);
}

template<class T>
CActiveHelper<T>* CActiveHelper<T>::NewL(const TPriority& aPriority)
	{
	CActiveHelper* ret = NewLC(aPriority);
	CleanupStack::Pop(ret);
	return ret;	
	}

template<class T>
CActiveHelper<T>* CActiveHelper<T>::NewLC(const TPriority& aPriority)
	{
	CActiveHelper* ret = new (ELeave) CActiveHelper<T>(aPriority);
	CleanupStack::PushL(ret);
	ret->ConstructL();
	return ret;
	}


template<class T>
void CActiveHelper<T>::DoCancel()
{
	return iTarget->MActiveHelperCallbackDoCancel(this, iUserData);
}

template<class T>
void CActiveHelper<T>::SetActive(MActiveHelperCallback<T>* aTarget, T aUserData)
	{
	iTarget = aTarget;
	iUserData = aUserData;
	CActive::SetActive();
	}

template<class T>
CActiveHelper<T>::~CActiveHelper()
	{
	Cancel();
	}

template<class T>
void CActiveHelper<T>::ConstructL()
	{
	iTarget = NULL;
	}


template<class T>
void CActiveHelper<T>::RunL()
	{
	iTarget->MActiveHelperCallbackRunL(this, iUserData);
	}

template<class T>
TInt CActiveHelper<T>::RunError(TInt aError)
	{
	return iTarget->MActiveHelperCallbackRunError(this, iUserData, aError);
	}

template<class T>
MActiveHelperCallback<T>::~MActiveHelperCallback()
	{	
	}
